package com.sxz.sbs.module.performance.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.performance.mode.FieldRankBean;
import com.sxz.sbs.module.performance.view.FieldRankView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;

/**
 * 案场榜P
 *
 * @author tian
 * @date 2018/1/18 0018
 */

public class FieldRankPresenter extends RxPresenter<FieldRankView>{
    /**
     * 获取案场榜
     * @param map
     */
    public void getFieldRank (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getFieldRank(map)
                .compose(RxUtil.<FieldRankBean>handleResult())
                .subscribeWith(new RxSubscriber<FieldRankBean>(mView){
                    @Override
                    public void onNext(FieldRankBean data) {
                        mView.onGetFieldRankSuccess(data);
                    }
                })
        );
    }
    /**
     * 添加案场榜
     * @param map
     */
    public void addFieldPraise (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().addFieldPraise(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onAddFieldPraiseSuccess();
                    }
                })
        );
    }
}
